package logik;

/**
 * @author Matthias
 * Abstract superclass Transaction represents an ATM transaction
 */
public abstract class Transaction {

	private PerformTransactions perform;

	// Transaction constructor invoked by subclasses using super()
	public Transaction(PerformTransactions perform) {
		this.perform = perform;
	} // end Transaction constructor

	public int getCPR_ID() {
		int currentCPR_ID = perform.getClassATM().getClassBankDatabase().getClassUser().getCPR();
		return currentCPR_ID;
	}
	
	public int getAccNr() {
		int AccNr = perform.getClassATM().getClassScreen().getChoiceAcc().getSpecificAccNr();
		return AccNr;
	}

	public double getTotBal() {
		double totalBalance = perform.getClassATM().getClassBankDatabase().getTotalBalance(getCPR_ID());
		return totalBalance;
	}
	
	public String getAccType(){
		String accountType = perform.getClassATM().getClassScreen().getChoiceAcc().getSpecificAccType();
		return accountType;
	}
	
	public double getInterestRate() {
		String ir = perform.getClassATM().getClassBankDatabase().getInterestRate(getAccType());
		return Double.parseDouble(ir);
	}
	
	public PerformTransactions getClassPerform(){
		return perform;
	}
	
	// perform the transaction (overridden by each subclass)
	abstract public void execute();

} // end class Transaction
